package com.itheima.utils;


import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

public class WebUtils {
    private WebUtils() {
    }

    public static <T> T copyParamToBean(Map value, T bean) {

        System.out.println("注入之前:" + bean);
        try {
            BeanUtils.populate(bean, value);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        System.out.println("注入之前:" + bean);

        return bean;
    }
}
